package com.example.day06.ex02;

import java.util.Scanner;

public class Test08 {
    public static void main(String[] args) {
        int []arr={1,2,3,4,5};
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入要查找的数据：");
        int number=sc.nextInt();
        int index=getIndex(arr,number);
        System.out.println("index:"+index);
    }
    public static int getIndex(int[] arr,int number){
        int index=-1;
        for(int i=0;i<arr.length;i++){
            if(arr[i]==number){
                index=i;
                break;
            }
        }
        return index;
    }
}
